cmake_minimum_required (VERSION 2.8.7)
project (backend)

set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/library)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(SOURCES_DIRECTORY ${PROJECT_SOURCE_DIR}/src)
set(INCLUDES_DIRECTORY ${PROJECT_SOURCE_DIR}/include)
set(EXAMPLE_DIRECTORY ${PROJECT_SOURCE_DIR}/example)

include_directories(${INCLUDES_DIRECTORY})
link_directories("${PROJECT_SOURCE_DIR}/library")

set(backend__DIRECTORY ${SOURCES_DIRECTORY}/)

foreach(dir ${backend__DIRECTORY})
  # get directory sources and headers
  file(GLOB s_${dir} "${dir}/*.c")
  file(GLOB h_${dir} "${dir}/*.h")

  # set sources
  set(backend_sources ${s_${dir}} ${h_${dir}})
endforeach()

add_library(backend ${backend_sources})
target_link_libraries(backend)


# 测试程序部分
add_subdirectory(${EXAMPLE_DIRECTORY}/)